package com.lovelyj.trip_by_train.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lovelyj.trip_by_train.entity.Coach;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.StatementType;

@Mapper
public interface CoachMapper extends BaseMapper<Coach> {

    @Select("{CALL save_with_seats(#{trainNum, mode=IN}, #{coachNum, mode=IN}, " +
            "#{seatRowNumber, mode=IN}, #{seatColNumber, mode=IN}, #{result, mode=OUT, jdbcType=INTEGER})}")
    @Options(statementType = StatementType.CALLABLE)
    void saveWithSeatsAndTickets(
            @Param("trainNum") String trainNum,
            @Param("coachNum") String coachNum,
            @Param("seatRowNumber") int seatRowNumber,
            @Param("seatColNumber") int seatColNumber,
            @Param("result") Integer result);

}
